package _3接口中使用泛型;

public class Impl2<T> implements Gen<T>
{
	// T  Object
	public T add(T a, T b) 
	{
		if(a instanceof Integer)
		{
			Integer x = (Integer)a;
			Integer y = (Integer)b;
			Integer result = x + y;
			return (T)result;
		}
		else if(a instanceof Double)
		{
			Double x = (Double)a;
			Double y = (Double)b;
			Double result = x + y;
			return (T)result;
		}
		
		else if(a instanceof String)
		{
			String x = (String)a;
			String y = (String)b;
			String result = x + y;
			return (T)result;
		}

		return null;
	};
}